home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_49349.txt < prev    next >
Text File  |  1991-02-27  |  950b  |  31 lines

  1. -- card: 49349 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 6
  9. ----- text -----
  10. 6.4  for
  11.  
  12. -- part contents for background part 4
  13. ----- text -----
  14. The 'for' loop is highly flexible.  Its syntax is simply:
  15.  
  16.     for (expression1 ; expression2 ; expression3)
  17.         statement
  18.  
  19. Expression1 is evaluated once upon entry to the loop, the statement is executed if expression2 evaluates to nonzero (true), and expression3 is evaluated at the end of each iteration of the loop.  Most commonly, expression1 is used as the loop initialization, expression2 as the loop condition, and expression3 to increment a loop counter.  For example:
  20.  
  21.     for (i=0 ; i<10 ; i++)
  22.         process_things(i);
  23.  
  24. The comma operator is useful to implement multiple counters:
  25.  
  26.     for (i=0,j=10  ;  i<10  ;  i++,j--)
  27.         process_things(i,j);
  28.  
  29. -- part contents for background part 7
  30. ----- text -----
  31. 165